<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderNum"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="状态">
              <a-select placeholder="请选择状态" v-model="queryParam.status">
                <a-select-option value="0">待申请</a-select-option>
                <a-select-option value="1">成功</a-select-option>
                <a-select-option value="5">进行中</a-select-option>
                <a-select-option value="6">拒绝</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="用户邮箱名">
              <a-input placeholder="请输入用户邮箱名" v-model="queryParam.userhome"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="银行卡号">
              <a-input placeholder="请输入用户" v-model="queryParam.bankNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('基金申购订单表')">导出</a-button>
      <!-- 高级查询区域 -->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="withrawType" slot-scope="text, record, index">
          <span v-if="text==1">微信</span>
            <span v-if="text==2">支付宝</span>
            <span v-if="text==3">银行卡</span>
        </span>
        <span slot="status" slot-scope="text, record, index">
            <a-tag color="#228af5" v-if="text==0">待审核</a-tag>
            <a-tag color="#87d068" v-if="text==1" >通过</a-tag>
            <a-tag color="#29cf13" v-if="text==5" >进行中</a-tag>
            <a-tag color="#cf1322" v-if="text==6" >拒绝</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <a @click="handleDetail(record)" v-if='record.status==0'>审核</a>
            <a @click="handleDetail2(record)" v-else style='color: #2eabff'>详情</a>
        </span>

      </a-table>
    </div>

    <withrawal-modal ref="modalForm" @ok="modalFormOk"></withrawal-modal>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import WithrawalModal from './modules/WithrawalModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
import { getAction } from '@api/manage'

export default {
  name: 'WithdrawalWalletOrderList',
  mixins:[JeecgListMixin, mixinDevice],
  components: {
    WithrawalModal
  },
  data () {
    return {
      description: '基金订单表管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'用户邮箱',
          align:"center",
          dataIndex: 'username'
        },
        {
          title:'用户电话',
          align:"center",
          dataIndex: 'phone'
        },
        {
          title:'交易类型',
          align:"center",
          dataIndex: 'type_dictText'
        },
        {
          title:'实际打款金额',
          align:"center",
          dataIndex: 'amount'
        },
        {
          title:'申请提现金额',
          align:"center",
          dataIndex: 'applyAmount'
        },
        {
          title:'订单号',
          align:"center",
          dataIndex: 'orderNum'
        },
        {
          title:'提现方式',
          align:"center",
          dataIndex: 'withrawType',
          scopedSlots: { customRender: 'withrawType' }
        },
        {
          title:'卡姓名',
          align:"center",
          dataIndex: 'accountName'
        },
        {
          title:'银行名',
          align:"center",
          dataIndex: 'bankName'
        },
        {
          title:'银行卡号',
          align:"center",
          dataIndex: 'bankNumber'
        },
        {
          title:'提现方式',
          align:"center",
          dataIndex: 'withrawType',
          scopedSlots: { customRender: 'withrawType' }
        },
        {
          title:'申请时间',
          align:"center",
          dataIndex: 'createTime'
        },
        {
          title:'处理时间',
          align:"center",
          dataIndex: 'examineTime'
        },
        {
          title:'状态',
          align:"center",
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align:"center",
          fixed:"right",
          width:147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/fund/userhomeOrder/list",
        delete: "/fund/userhomeOrder/delete",
        deleteBatch: "/fund/userhomeOrder/deleteBatch",
        exportXlsUrl: "/fund/userhomeOrder/exportXls",
        importExcelUrl: "fund/userhomeOrder/importExcel",

      },
      dictOptions:{},
      superFieldList:[],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig(){
      this.queryParam.type=4
      this.loadData();
    },
    handleDetail2(record)
    {
      this.$refs.modalForm.show(record);
    },
    loadData(arg) {
      if(!this.url.list){
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      debugger
      if(this.queryParam.type==null) {
        return false;
      }
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records||res.result;
          if(res.result.total)
          {
            this.ipagination.total = res.result.total;
          }else{
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        }else{
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    getSuperFieldList(){
      let fieldList=[];
      fieldList.push({type:'string',value:'fundName',text:'基金名',dictCode:''})
      fieldList.push({type:'int',value:'type',text:'交易类型(1申购 2赎回 3提现)',dictCode:'order_type'})
      fieldList.push({type:'BigDecimal',value:'amount',text:'金额',dictCode:''})
      fieldList.push({type:'int',value:'status',text:'状态(0 进行中 1成功 2过期 3异常 4失败)',dictCode:'order_status'})
      fieldList.push({type:'string',value:'orderNum',text:'订单号',dictCode:''})
      fieldList.push({type:'string',value:'payNum',text:'第三方订单号',dictCode:''})
      fieldList.push({type:'string',value:'relationId',text:'申购id',dictCode:''})
      fieldList.push({type:'int',value:'payType',text:'支付方式 1 支付宝 2微信 3 网银 4银盛支付宝 5银盛微信 6银盛网银',dictCode:'pay_type'})
      fieldList.push({type:'string',value:'fundCode',text:'基金code',dictCode:''})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>